export interface Message_Data {
    FromUserName: string;
    ToUserName: string;
    Content: string;
    StatusNotifyUserName: string;
    ImgWidth: number;
    PlayLength: number;
    RecommendInfo: any;
    StatusNotifyCode: number;
    NewMsgId: string;
    Status: number;
    VoiceLength: number;
    ForwardFlag: number;
    AppMsgType: number;
    Ticket: string;
    AppInfo: any;
    Url: string;
    ImgStatus: number;
    MsgType: number;
    ImgHeight: number;
    MediaId: string;
    MsgId: string;
    FileName: string;
    HasProductId: number;
    FileSize: string;
    CreateTime: number;
    SubMsgType: number;
}
export interface Message extends Message_Data {
    isSendBySelf: boolean;
    isSendBy(contact: Contact_Data): boolean;
    getPeerUserName(): string;
    getDisplayTime(): string;
    OriginalContent: string;
}
export interface Contact_Data {
    RemarkName: string;
    DisplayName: string;
    Uin: number;
    UserName: string;
    NickName: string;
    HeadImgUrl: string;
    ContactFlag: number;
    MemberCount: number;
    MemberList: Contact_Data[];
    HideInputBarFlag: number;
    Sex: number;
    Signature: string;
    VerifyFlag: number;
    OwnerUin: number;
    PYInitial: string;
    PYQuanPin: string;
    RemarkPYInitial: string;
    RemarkPYQuanPin: string;
    StarFriend: number;
    AppAccountFlag: number;
    Statues: number;
    AttrStatus: number;
    Province: string;
    City: string;
    Alias: string;
    SnsFlag: number;
    UniFriend: number;
    ChatRoomId: number;
    KeyWord: string;
    EncryChatRoomId: string;
}
export interface Contact extends Contact_Data {
    // getDisplayName(): string;
    canSearch(key: string): boolean;
    isSelf: boolean;
    AvatarUrl: string;
}
export function getDisplayName(contact: Contact_Data): string {
    return convertEmoji(contact.DisplayName || contact.RemarkName || contact.NickName);

}
export function convertEmoji(s) {
    return s ? s.replace(/<span.*?class="emoji emoji(.*?)"><\/span>/g, (a, b) => {
        switch (b.toLowerCase()) {
            case '1f639':
                b = '1f602'
                break
            case '1f64d':
                b = '1f614'
                break
        }
        try {
            let s = null
            if (b.length === 4 || b.length === 5) {
                s = ['0x' + b]
            } else if (b.length === 8) {
                s = ['0x' + b.slice(0, 4), '0x' + b.slice(4, 8)]
            } else if (b.length === 10) {
                s = ['0x' + b.slice(0, 5), '0x' + b.slice(5, 10)]
            } else {
                throw new Error('unknown emoji characters')
            }
            return String.fromCodePoint.apply(null, s)
        } catch (err) {

            return '*'
        }
    }) : ''
}
